package com.wx.springboot.step9back.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Set;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "用户",description = "用户实体类")
public class User extends BaseModel implements Serializable, UserDetails {

    @ApiModelProperty(value = "userCode",example="用户编号，唯一")
    private String userCode;
    @ApiModelProperty(value = "password",example="用户密码")
    private String password;
    @ApiModelProperty(value = "code",example="验证码")
    private String code;
    @ApiModelProperty(value = "checkCode",example="验证码判断")
    private String checkCode;
    @ApiModelProperty(value = "name",example="用户姓名")
    private String name;
    @ApiModelProperty(value = "sexCode",example="性别code")
    private String sexCode;
    @ApiModelProperty(value = "sexName",example="性别名")
    private String sexName;
    @ApiModelProperty(value = "teamCode",example="小组编号")
    private String teamCode;
    @ApiModelProperty(value = "teamName",example="小组名字")
    private String teamName;
    @ApiModelProperty(value = "education",example="学历code")
    private String education;
    @ApiModelProperty(value = "educationName",example="学历名")
    private String educationName;
    @ApiModelProperty(value = "address",example="地址")
    private String address;
    @ApiModelProperty(value = "phone",example="电话")
    private String phone;
    @ApiModelProperty(value = "roleId",example="角色id")
    private String roleId;
    @ApiModelProperty(value = "roleName",example="角色名字")
    private String roleName;
    @ApiModelProperty(value = "userState",example="用户状态")
    private String userState;

    private Set<? extends GrantedAuthority> authorities;

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.userCode;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
    public void setAccountNonExpired(String accountNonExpired) {
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }
    public void setAccountNonLocked(String accountNonLocked) {
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }
    public void setCredentialsNonExpired(String credentialsNonExpired) {
    }

    @Override
    public boolean isEnabled() {
        if(this.getStateCode()==null){
            return false;
        }
        return this.getStateCode()=="1";
    }
    public void setEnabled(String enabled) {
    }
}
